"use strict";
const path = require("path");
const paths = require("./paths");

module.exports = {
  entry: {
    main: path.join(__dirname, "src/main.ts"),
  },
  node: {
    __dirname: false,
    __filename: false,
  },
  output: {
    filename: "index.js",
    path: path.join(__dirname, "./dist"),
  },
  target: "electron-main",
  module: {
    rules: [
      {
        test: /\.(js|mjs|jsx|ts|tsx)$/,
        include: paths.appSrc,
        loader: require.resolve("babel-loader"),
        options: {
          customize: require.resolve(
            "babel-preset-react-app/webpack-overrides"
          ),
          presets: ["@babel/preset-env"],
          plugins: [
            [
              require.resolve("babel-plugin-named-asset-import"),
              {
                loaderMap: {
                  svg: {
                    ReactComponent:
                      "@svgr/webpack?-svgo,+titleProp,+ref![path]",
                  },
                },
              },
            ],
          ],
        },
      },
    ],
  },
};
